package cc.telecomdigital.tdstock.model;

import java.util.HashMap;

public class Top20StockInfo
{
	public final static int						RECORD_TOTAL_NUMBER	= 20;
	public final static int						COLUMN_TOTAL_NUMBER	= 5;
	public final static String					ADAPTER			= "STOCKLIST";
	public final static String[]					ITEMS			= {
			"NetGainers", "NetLosers", "TopTurnover", "TopVolume",
			"WarrantNetGainers", "WarrantNetLosers", "WarrantTopTurnover",
			"WarrantTopVolume"									};
	public final static String					STOCK			= "Stock";
	public final static String					NAME				= "Name";
	public final static String					NOMINAL			= "Nominal";
	public final static String					NET				= "Net";
	public final static String					NETPERCENTAGE		= "NetPercentage";
	public final static String					TURNOVER			= "Turnover";
	public final static String					SHARETRADED		= "ShareTraded";

	public final static HashMap<String, String[]>	ITEM_FIELDS		= new HashMap<String, String[]>();
	static
	{

		for (int item = 0; item < ITEMS.length; item++)
		{

			switch (item)
			{
				case 0:
				case 1:
				case 4:
				case 5:
					String[] fields = new String[RECORD_TOTAL_NUMBER
							* COLUMN_TOTAL_NUMBER];
					for (int index = 0; index < RECORD_TOTAL_NUMBER; index++)
					{
						fields[index] = STOCK + (index + 1);
						fields[RECORD_TOTAL_NUMBER + index] = NAME
								+ (index + 1);
						fields[RECORD_TOTAL_NUMBER * 2 + index] = NOMINAL
								+ (index + 1);
						fields[RECORD_TOTAL_NUMBER * 3 + index] = NET
								+ (index + 1);
						fields[RECORD_TOTAL_NUMBER * 4 + index] = NETPERCENTAGE
								+ (index + 1);
					}
					ITEM_FIELDS.put(ITEMS[item], fields);
					break;
				default:
					String[] currFields = new String[RECORD_TOTAL_NUMBER
							* COLUMN_TOTAL_NUMBER];
					for (int index = 0; index < RECORD_TOTAL_NUMBER; index++)
					{
						currFields[index] = STOCK + (index + 1);
						currFields[RECORD_TOTAL_NUMBER + index] = NAME
								+ (index + 1);
						currFields[RECORD_TOTAL_NUMBER * 2 + index] = NOMINAL
								+ (index + 1);
						currFields[RECORD_TOTAL_NUMBER * 3 + index] = SHARETRADED
								+ (index + 1);
						currFields[RECORD_TOTAL_NUMBER * 4 + index] = TURNOVER
								+ (index + 1);
					}
					ITEM_FIELDS.put(ITEMS[item], currFields);
					break;
			}

		}

	}

	public static String getFieldName(String item, int fieldIndex)
	{
		String result = null;
		String[] fields = ITEM_FIELDS.get(item);
		result = fields == null ? null : fields[fieldIndex];
		return result;
	}

}
